#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
const int N = 5e4 + 10;
LL arr[N];
int n, m;
LL s[N];
	int main()
	{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &arr[i]);
		s[i] = arr[i] + s[i - 1];
	}
	scanf("%d", &m);
	while (m--) {
		int l, k;
		scanf("%d%d", &l, &k);
		printf("%lld\n", s[l + k - 1] - s[l -1]);
	}
	return 0;
}